package com.hjt.common.utils;

import java.util.Random;

/**
 * @author:97007
 * @date:2021/9/28 15:49
 */
public class RandomUtils {
    public static String getRandomCode(int bit) {
        StringBuffer sbf = new StringBuffer();
        Random random = new Random();

        while (bit-->0) {
            if (random.nextBoolean()) {
                sbf.append(random.nextInt(10));
            } else {
                if (random.nextBoolean()) {
                    sbf.append((char)(random.nextInt(26) + 65));
                } else {
                    sbf.append((char)(random.nextInt(26) + 97));
                }
            }
        }
        return sbf.toString();
    }
}
